import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { increment, decrement } from '@/action';


@connect(state => ({
  val: state.counter,
}), { increment, decrement })
class Counter extends Component {
  static propTypes = {
    val: PropTypes.number.isRequired,
    increment: PropTypes.func.isRequired,
    decrement: PropTypes.func.isRequired
  }
  render() {
    const { val,increment,decrement } = this.props;
    return (
      <div>
        <p className="App-intro">
          {val}
        </p>
        <button onClick={() => { increment() }}>INCREMENT</button>
        <button onClick={() => { decrement() }}>DECREMENT</button>
      </div>
    )
  }
};
export default Counter;